package com.shiguiwu.springboot3.filter;

import lombok.Data;
import net.sf.jsqlparser.expression.Expression;
import net.sf.jsqlparser.expression.ExpressionVisitorAdapter;
import net.sf.jsqlparser.schema.Column;
import net.sf.jsqlparser.statement.Statement;
import org.springframework.jdbc.datasource.ConnectionHolder;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.interceptor.TransactionAspectSupport;
import org.springframework.transaction.support.TransactionSynchronizationManager;

import java.util.List;
import java.util.Set;
import java.util.stream.IntStream;

/**
 * @description:
 * @author: stone
 * @date: Created by 2023/7/21 20:21
 * @version: 1.0.0
 * @pakeage: com.shiguiwu.springboot3.filter
 */
@Data
public abstract class AbstractSqlFilter {

    private Statement statement;


    public boolean isSupport() {
        return false;
    }


    public void handleSql(Set<String> cols) {

    }

    public void handleWhere(Set<String> cols, Expression expression) {
        if (expression != null) {
            expression.accept(new ExpressionVisitorAdapter() {
                @Override
                public void visit(Column column) {
                    cols.add(column.getColumnName());
                }
            });
        }
    }

}
